import type { MockConfig, MockMethod } from "vite-plugin-mock";

import Mock from "mockjs";
import { exampleSongs } from "./songs-data.ts";
import baseResponse from "./base";

export default (config?: MockConfig) => {
  return [
    {
      url: "/api/search",
      method: "get",
      response: ({ body,query }: {body:any,query: any}) => {
        const { query: keyword } = query;
        const songs = exampleSongs.filter((item) => {
          return item.name.includes(keyword);
        });
        const data = {
          songs,
        };
        return baseResponse.success(data);
      }

    }
  ] as MockMethod[];
}


